Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS region to the AWS Config Cache key #6134

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

maxbog
Copy link

@maxbog maxbog commented Sep 4, 2024

The PR adds the AWS region to the key used by the AWS config cache

Checklist

Fixes #6128

@maxbog maxbog requested a review from a team as a code owner September 4, 2024 09:37
@maxbog maxbog force-pushed the region_in_aws_config_cache branch 4 times, most recently from e025102 to a67350c Compare September 4, 2024 13:49
Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is broken

Signed-off-by: Maksymilian Boguń <[email protected]>
@maxbog
Copy link
Author

maxbog commented Sep 18, 2024

@zroubalik I fixed the build

@zroubalik
Copy link
Member

zroubalik commented Sep 18, 2024

/run-e2e aws
Update: You can check the progress here

@zroubalik
Copy link
Member

zroubalik commented Sep 19, 2024

/run-e2e aws
Update: You can check the progress here

@maxbog
Copy link
Author

maxbog commented Sep 24, 2024

@zroubalik Is something wrong with the e2e tests? I see they failed twice now :(

@zroubalik
Copy link
Member

@zroubalik Is something wrong with the e2e tests? I see they failed twice now :(

yeah, issue on our side, will rerun once it is fixed

@ndlanier
Copy link

ndlanier commented Oct 4, 2024

@zroubalik any updates on the e2e testing?

@JorTurFer
Copy link
Member

JorTurFer commented Oct 6, 2024

/run-e2e aws
Update: You can check the progress here

@maxbog
Copy link
Author

maxbog commented Oct 9, 2024

@JorTurFer I rebased the PR
Now the tests failed, but it looks like some random crash, can you please rerun the failing job and the e2e tests?

@JorTurFer
Copy link
Member

JorTurFer commented Oct 16, 2024

/run-e2e aws
Update: You can check the progress here

Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL @kedacore/keda-core-contributors

@JorTurFer JorTurFer enabled auto-merge (squash) October 16, 2024 18:00
@ndlanier
Copy link

ndlanier commented Oct 28, 2024

Any insight into why it paniced/failed on the amd64 validation?

@ndlanier
Copy link

@JorTurFer is the validate - amd64 stage failure an issue with the action or an issue with the code changes in this pr?

@JorTurFer
Copy link
Member

@JorTurFer is the validate - amd64 stage failure an issue with the action or an issue with the code changes in this pr?

I've triggered it again because probably it was a transient error

@JorTurFer
Copy link
Member

@zroubalik @wozniakjan PTAL

@JorTurFer JorTurFer enabled auto-merge (squash) October 31, 2024 00:47
@JorTurFer
Copy link
Member

JorTurFer commented Nov 2, 2024

/run-e2e aws
Update: You can check the progress here

@JorTurFer JorTurFer mentioned this pull request Nov 3, 2024
28 tasks
@ThaSami
Copy link
Contributor

ThaSami commented Nov 4, 2024

Great catch

@ThaSami
Copy link
Contributor

ThaSami commented Nov 4, 2024

i would suggest to add Region in aws authorization metadata, rather than passing it all around.

https://github.com/kedacore/keda/blob/5ea1eac06e536a04cdf22383faff9e91bd374f17/pkg/scalers/aws/aws_authorization.go#L18C1-L35

wdyt @JorTurFer ?

@JorTurFer
Copy link
Member

i would suggest to add Region in aws authorization metadata, rather than passing it all around.

5ea1eac/pkg/scalers/aws/aws_authorization.go#L18C1-L35

wdyt @JorTurFer ?

That's a good idea tbh. Could you update the PR @maxbog ?

@maxbog
Copy link
Author

maxbog commented Nov 4, 2024

@JorTurFer @ThaSami
Thanks for the review.
At first glance, I also thought this might be a good idea. However, after digging into the code, I'm not that convinced anymore. Here are the reasons:

  1. Although the AuthorizationMetadata struct has Authorization in the name, what it really represents is an AWS identity: a role + credentials coming from pod identity or the AccessKey/SecretAccessKey pair. Identities are global in AWS, so IMO, region does not belong in this struct. Region is actually only used when creating AWS clients, to specify, where the queried services are, not where the identity is located.
  2. We would get rid of the awsRegion parameter in the getCacheKey function, but then, if we still want to add it to the AuthorizationMetadata, we need to add a awsRegion parameter to the GetAwsAuthorization function, which, in turn, means we have to pass it from the different types of scaler metadata (for example, here, here, or here, or 5 different places)
  3. Having the awsRegion parameter in the getCacheKey actually makes sense when you look at the AuthorizationMetadata as an identity. The aws.Config struct represents a AWS service client configuration, so IMO it makes perfect sense to cache it for a specific identity and for a specific region. We lose expressiveness by hiding the region in the awsAuthorization parameter.

Please let me know, if, after taking the above into account, you still want to update the PR and add the region to the AuthorizationMetadata.

@ThaSami
Copy link
Contributor

ThaSami commented Nov 5, 2024

Although the AuthorizationMetadata struct has Authorization in the name, what it really represents is an AWS identity: a role + credentials coming from pod identity or the AccessKey/SecretAccessKey pair.

Exactly - that's what sparked this idea for me. Since credentials are part of identity, obtaining them in the AWS SDK requires specifying a region as STS endpoints are regional.
that's why i believe including AwsRegion within the AuthorizationMetadata struct makes architectural sense because:

  1. keeps all authentication-related data in one cohesive unit
  2. Ensures the region information is always available when making credential requests
  3. maintains a clear relationship between authorization data and its associated AWS region

would like to hear from @JorTurFer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS credentials cache key needs to include the region
5 participants